package com.app.mymusic.ui.charts;

import com.app.mymusic.common.Constants;
import com.app.mymusic.model.Songs;
import com.app.mymusic.utils.LogUtil;
import com.app.mymusic.utils.RetrofitUtil;

import rx.Subscriber;

/**
 * Created by Administrator on 2016-12-7.
 */

public class ChartsModel {

    public ChartsModel() {
    }

    public void getCharts(String type,String offset, final ChartsPresenter.ChartsCallback callback){
        RetrofitUtil.getInstace().initRetrofit(Constants.tingIrl)
                .getCharts("1", "0", new Subscriber<Songs>() {
                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {
                        LogUtil.showLog("music-error:"+e.toString());
                        callback.error();
                    }

                    @Override
                    public void onNext(Songs songs) {
                        try {
                            LogUtil.showLog("music:"+songs.getSong_list().get(1).getTitle());
                            callback.success(songs);
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                });
    }
}
